import { Injectable } from '@angular/core';
import { RequestClass } from './request.service';
@Injectable()
export class PlanService {
    constructor(private requestclass: RequestClass) {}

    // 4.6 新接口
    // 通过机井 id，获取年度用水量列表
    // http://115.157.195.222:3000/project/16/interface/api/96
    fetchYearPlanListById = async ({ id }) => {
        return await this.requestclass.request.get('/wellinfo/getplanwater', {
            params: {
                well_id: id,
            },
        });
    };

    // 4.8 新接口
    // 通过机井 id，更新年度计划用水量
    // http://115.157.195.222:3000/project/16/interface/api/98
    updateYearPlanById = async ({
        applicantId,
        planType,
        planVolume,
        planYear,
    }) => {
        return await this.requestclass.request.post('/plan/insertplanvolume', {
            data: {
                applicantId,
                planType,
                planVolume: (planVolume || 0) * 10000,
                planYear,
            },
        });
    };

    addYearPlanById = async ({ wellId, planVolume, planYear }) => {
        return await this.requestclass.request.post(
            '/wellinfo/insertplanwater',
            {
                data: {
                    wellId,
                    planVolume,
                    planYear,
                },
            }
        );
    };
}
